<?php


namespace app\admin\validate\setting;

use tmcore\base\BaseValidate;

/**
 * 短信配置验证器
 */
class SmsValidate extends BaseValidate
{

    protected $rule = [
        'status' => 'require',
        'identify' => 'require|checkIdentify',
    ];

    protected $message = [
        'status.require' => '状态不能为空',
        'identify.require' => '短信渠道参数不能为空',
    ];

    /**
     * 设置短信参数场景
     * @return SmsValidate
     */
    public function sceneEdit()
    {
        return $this->only(['identify','status']);
    }


    /**
     * 获取配置参数信息场景
     * @return SmsValidate
     */
    public function sceneDetail()
    {
        return $this->only(['identify']);
    }


    /**
     * 切换短信场景
     * @return SmsValidate
     */
    public function sceneChange()
    {
        return $this->only(['identify']);
    }

    /**
     * 检查短信标识
     * @param $value
     * @return bool|string
     */
    public function checkIdentify($value)
    {
        if(!in_array($value, ['aliyun','tencent'])) return '短信标识参数错误';
        return true;
    }
}